<div class="row m-n">
    <div class="crumbs-bar">
        <div yb-crumbs></div>
    </div>
    <div tabset type="tab">
        <div tab heading="三日计划" active="activeFlag[0]" ng-click="changeTab(0)">
            <div class="row wrapper-y-sm">
                <div class="operate-bar col-xs-4 font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="goAdd()"
                            ng-disabled="!btnPermission.threeDayPlanAdd" title="{{!btnPermission.threeDayPlanAdd?'无权限执行此操作':''}}">新增
                    </button>
                    <button class="btn btn-operate m-r-sm" ng-click="batchDeletePlan()"
                            ng-disabled="!btnPermission.threeDayPlanDelete" title="{{!btnPermission.threeDayPlanDelete?'无权限执行此操作':''}}">批量删除</button>
                </div>
                <div class="search-bar wrapper-none col-xs-8">
                    <div class="btn-group m-l-xs pull-right">
                        <button type="button" class="btn btn-default base-color" ng-click="search()" title="刷新">
                            <i class="yb-icon ico-refresh"></i>
                        </button>
                        <button type="button" class="btn btn-default base-color" title="配置表格列"
                                ng-click="switchToolbar('ColConfig');">
                            <i class="yb-icon ico-set"></i>
                        </button>
                    </div>
                    <button class="btn-advance pull-right m-l-xs" ng-click="switchToolbar('AdvanceSearch')">高级搜索
                    </button>
                    <div class="input-group pull-right clearfix">
                        <input type="text" class="form-control txt-search" placeholder="代理商名称"
                               ng-model="condition.agentName">
                        <span class="input-group-addon cursor-pointer" ng-click="searchDataList(1)">搜索</span>
                    </div>
                </div>
            </div>
            <div yb-advance-search show-toolbar="toolbarConfig.showAdvanceSearch" search-data="searchDataList(1)"
                 reset-data="reset('condition')">
                <div class="advance-search m-t-sm">
                    <div class="form-group clearfix">
                        <label class="control-label">代理商名称：</label>
                        <input type="text" ng-model="condition.agentName" class="form-control">
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">单据类型：</label>
                        <select ng-model="condition.orderType" class="form-control"
                                ng-options="item.code as item.name for item in billTypeList">
                            <option value="">请选择</option>
                        </select>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">是否创建发运交货单：</label>
                        <select ng-model="condition.isDlv" class="form-control"
                                ng-options="item.id as item.name for item in isBooleanList">
                            <option value="">请选择</option>
                        </select>
                    </div>
                    <div class="form-group clearfix m-b-none">
                        <label class="control-label">计划时间：</label>
                        <input type="text" class="form-control date-picker" ng-model="condition.startPlanDate"
                               datepicker-popup="{{'yyyy-MM-dd'}}"
                               ng-click="showCreateDateStart = !showCreateDateStart"
                               ng-change="checkDate(condition, 'startPlanDate', 'endPlanDate')"
                               is-open="showCreateDateStart" close-text="关闭" modal-size="small" readonly>
                    </div>
                    <div class="form-group clearfix m-b-none">
                        <label class="control-label"></label>
                        <label class="control-label wave-line">~</label>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label"></label>
                        <input type="text" class="form-control date-picker" ng-model="condition.endPlanDate"
                               datepicker-popup="{{'yyyy-MM-dd'}}"
                               ng-click="showCreateDateEnd = !showCreateDateEnd"
                               ng-change="checkDate(condition, 'startPlanDate', 'endPlanDate')"
                               is-open="showCreateDateEnd" close-text="关闭" modal-size="small" readonly>
                    </div>
                </div>
            </div>
            <div yb-col-config show-toolbar="toolbarConfig.showColConfig" ng-model="listTbConfig" col-fixed="true"
                 has-check-col="true" set-tb-style="setFixedWidth()"></div>
            <div class="main-area">
                <div yb-table-fixed class="table-fixed-wrap fix-left" ele-count="4" scroll-area="right">
                    <div class="th-fixed">
                        <table class="table-fixed border-none" width="{{tableConfig.fixedWidth}}">
                            <thead>
                            <tr>
                                <th width="40" class="text-center th-check border-l-none">
                                    <div yb-check-box yb-checked="markInfo.allChecked" yb-click="selectAll(dataList, 'allChecked')"></div>
                                </th>
                                <th ng-repeat="itemCol in listTbConfig.tableCol track by $index"
                                    width="{{itemCol.width}}" ng-show="!!itemCol.isShow && !!itemCol.isFixed">
                                    <div yb-thead-operate ng-model="itemCol" target-width="listTbConfig.scrollWidth"
                                         fixed-width="listTbConfig.fixedWidth"></div>
                                </th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="th-scroll-x" ng-style="tbStyle.billFixedWidth">
                        <table class="table-fixed border-none" width="{{listTbConfig.scrollWidth}}">
                            <thead>
                            <tr>
                                <th ng-repeat="itemCol in listTbConfig.tableCol track by $index"
                                    width="{{itemCol.width}}" ng-show="!!itemCol.isShow && !itemCol.isFixed">
                                    <div yb-thead-operate ng-model="itemCol"
                                         target-width="listTbConfig.scrollWidth"></div>
                                </th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll-y" ng-show="dataList.length > 0">
                        <table class="table-fixed border-none" width="{{listTbConfig.fixedWidth}}">
                            <tbody>
                            <tr ng-repeat="item in dataList track by $index">
                                <td width="40" class="text-center border-l-none">
                                    <div yb-check-box yb-checked="item.isChecked"
                                         yb-click="selectSingle(item, dataList, 'allChecked')"></div>
                                </td>
                                <td class="spill-dots" ng-repeat="itemCol in listTbConfig.tableCol track by $index"
                                    width="{{itemCol.width}}" ng-show="!!itemCol.isShow && !!itemCol.isFixed"
                                    title="{{item[itemCol.dataField]}}">
                                    <div >
                                        <button type="button" class="btn btn-operate m-r-xs" ng-click="deleteSinglePlan(item.id)"
                                                ng-disabled="!btnPermission.threeDayPlanDelete || item.isDlv === 1"
                                                title="{{!btnPermission.threeDayPlanDelete?'无权限执行此操作':''}}">删除
                                        </button>
                                        <button type="button" class="btn btn-operate m-r-xs" ng-click="goEdit(item)"
                                                ng-disabled="!btnPermission.threeDayPlanEdit || item.isDlv === 1"
                                                title="{{!btnPermission.threeDayPlanEdit?'无权限执行此操作':''}}">编辑
                                        </button>
                                        <button type="button" class="btn btn-operate m-r-xs"
                                                ng-click="viewDetail(item)">详情
                                        </button>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="dataList.length > 0" ng-style="tbStyle.billFixedWidth">
                        <table class="table-fixed border-none" width="{{listTbConfig.scrollWidth}}">
                            <tbody>
                            <tr ng-repeat="item in dataList track by $index">
                                <td class="spill-dots" ng-repeat="itemCol in listTbConfig.tableCol track by $index"
                                    width="{{itemCol.width}}" title="{{item[itemCol.dataField]}}"
                                    ng-show="!!itemCol.isShow && !itemCol.isFixed">
                                    <div ng-switch="itemCol.type">
                                        <div ng-switch-when="click">
                                            <a class="btn-operate m-r-xs" ng-class="{'danger-color': !!item.isReverse}" ng-click="tdClick(item, itemCol.clickFn)">
                                                {{item[itemCol.dataField]}}
                                            </a>
                                        </div>
                                        <div ng-switch-default>
                                            <span>{{item[itemCol.dataField]}}</span>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="dataList.length === 0">暂时没有数据</div>
                </div>
            </div>
            <div class="bottom-area page-bar wrapper-y-sm clearfix">
                <div yb-check-box class="m-t-xs m-r-sm" yb-checked="markInfo.allChecked" yb-check-name="全选"
                     yb-click="selectAll(dataList, 'allChecked')"></div>
                <div yb-page-info ng-model="pageInfo" yb-refresh="searchDataList()"></div>
            </div>
        </div>
        <div tab heading="{{tabFlag.name}}" active="activeFlag[1]" ng-if="activeFlag[1]">
            <form name="orderForm" class="m-t form-horizontal form-up-tb border-b clearfix" novalidate>
                <div class="form-group col-xs-4 m-b-sm">
                    <label class="col-xs-5 control-label max-w-100"><i>*</i>订单类型：</label>
                    <div class="col-xs-7 wrapper-none">
                        <select class="form-control" ng-model="detailInfo.orderType" name="orderType"
                                ng-options="item.code as item.name for item in billTypeList" required ng-disabled="tabFlag.type === 1">
                            <option value="">请选择</option>
                        </select>
                        <div class="msg-block" ng-show="orderForm.orderType.$dirty || (orderForm.orderType.$invalid && submitted)">
                            <div class="error-msg" ng-if="orderForm.orderType.$error.required">
                                <div class="msg-triangle"></div>
                                必填项，请填写
                            </div>
                        </div>
                    </div>
                </div>

                <div class="form-group col-xs-4 m-b-sm">
                    <label class="col-xs-5 control-label max-w-100"><i>*</i>客户名称：</label>
                    <div class="col-xs-7 wrapper-none" ng-if="tabFlag.type === 0">
                        <input type="text" name="clientName" class="form-control light-bg" ng-model="detailInfo.clientName"
                               ng-click="selectDealer()" required yb-focus readonly placeholder="请选择">
                        <div class="msg-block" ng-if="orderForm.clientName.$dirty || (orderForm.clientName.$invalid && submitted)">
                            <div class="error-msg" ng-if="orderForm.clientName.$error.required && !orderForm.clientName.focused">
                                <div class="msg-triangle"></div>
                                必填项，请填写
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-7 wrapper-none" ng-if="tabFlag.type === 1">
                        <input type="text" name="clientName" class="form-control" ng-model="detailInfo.clientName"
                               ng-click="selectDealer()" required yb-focus readonly placeholder="请选择" ng-disabled="true">
                    </div>
                </div>

                <div class="form-group col-xs-4 m-b-sm">
                    <label class="col-xs-5 control-label"><i>*</i>计划时间：</label>
                    <div class="col-xs-7 wrapper-none">
                        <input type="text" class="form-control date-picker" ng-model="detailInfo.planDate" name="planDate"
                               datepicker-popup="{{'yyyy-MM-dd'}}" ng-click="switchDataPicker(0)" is-open="datePickerFlag[0]" close-text="关闭"
                               ng-change="checkDate(detailInfo, 'planDate')" readonly required>
                    </div>
                    <div class="col-xs-4 msg-block"
                         ng-show="orderForm.planDate.$dirty || (orderForm.planDate.$invalid && submitted)">
                        <div class="error-msg" ng-if="orderForm.planDate.$error.required && !orderForm.planDate.focused">
                            <i class="yb-icon ico-times-circular"></i>必填项，请填写
                        </div>
                    </div>
                </div>
            </form>
            <div class="pos-a-full" style="right: 50%;top: 100px;">
                <div class="row wrapper-y-sm">
                    <div class="search-bar wrapper-none col-xs-6 pull-right">
                        <div class="input-group pull-right clearfix">
                            <input type="text" class="form-control txt-search" placeholder="单据号"
                                   ng-model="detailInfo.keyWords">
                            <span class="input-group-addon cursor-pointer" ng-click="searchBill(1)">搜索</span>
                        </div>
                    </div>
                </div>

                <div yb-table-fixed class="table-fixed-wrap fix-left" ele-count="4" scroll-area="right" style="top:50px; bottom: 50px;" >
                    <div class="th-fixed">
                        <table class="table-fixed border-none" width="{{addLeftTbConfig.fixedWidth}}">
                            <thead>
                                <tr>
                                    <th width="40" class="text-center th-check border-l-none">
                                        <div yb-check-box yb-checked="markInfo.allBillChecked" yb-click="selectAllOrder()"></div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="th-scroll-x" style="left:40px">
                        <table class="table-fixed border-none" width="{{addLeftTbConfig.scrollWidth}}">
                            <thead>
                                <tr>
                                    <th ng-repeat="itemCol in addLeftTbConfig.tableCol track by $index" width="{{itemCol.width}}"
                                        ng-show="!!itemCol.isShow && !itemCol.isFixed">
                                        <div yb-thead-operate ng-model="itemCol" target-width="addLeftTableConfig.scrollWidth"></div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll-y" ng-show="orderDataList.length > 0">
                        <table class="table-fixed border-none" width="{{addLeftTbConfig.fixedWidth}}">
                            <tbody>
                                <tr ng-repeat="item in orderDataList track by $index">
                                    <td width="40" class="text-center border-l-none">
                                        <div yb-check-box yb-checked="item.isChecked" yb-click="selectSingleOrder(item)"></div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="orderDataList.length > 0" style="left:40px">
                        <table class="table-fixed border-none" width="{{addLeftTbConfig.scrollWidth}}">
                            <tbody>
                                <tr ng-repeat="item in orderDataList track by $index">
                                    <td class="spill-dots" ng-repeat="itemCol in addLeftTbConfig.tableCol track by $index" width="{{itemCol.width}}"
                                        ng-show="!!itemCol.isShow && !itemCol.isFixed"
                                        title="{{item[itemCol.dataField]}}">
                                        <span ng-if="!itemCol.clickFn && itemCol.type !== 'operate'">{{item[itemCol.dataField]}}</span>
                                        <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)" ng-if="!!itemCol.clickFn">
                                            {{item[itemCol.dataField]}}
                                        </a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="orderDataList.length === 0">暂时没有数据</div>
                </div>
                <div class="bottom-area page-bar wrapper-y-sm clearfix">
                    <div yb-check-box class="m-t-xs m-r-sm" yb-checked="markInfo.allBillChecked" yb-check-name="全选"
                         yb-click="selectAllOrder()"></div>
                    <div yb-page-info ng-model="addPageInfo" yb-refresh="searchBill()"></div>
                </div>
            </div>
            <div class="pos-a-full" style="left: 50%; padding-left: 10px;top: 100px;">
                <div class="row wrapper-y-sm">
                    <div class="panel-bar clearfix">
                        <div class="pull-left">
                            <i></i>已选单据
                        </div>
                    </div>
                </div>
                <div yb-table-fixed class="table-fixed-wrap" style="top:50px; bottom: 50px; left: 10px;" >
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="100%">
                            <thead>
                            <tr>
                                <th width="30%">业务单号</th>
                                <th width="30%">客户名称</th>
                                <th width="30%">采购级别</th>
                                <th width="10%">操作</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="selectedList.length > 0">
                        <table class="table-fixed border-none" width="100%">
                            <tbody>
                            <tr ng-repeat="item in selectedList track by $index">
                                <td  width="30%" class="spill-dots" title="{{item.deliveryNo}}">{{item.deliveryNo}}</td>
                                <td  width="30%" class="spill-dots" title="{{item.purchaseOrgName}}">{{item.purchaseOrgName}}</td>
                                <td  width="30%" class="spill-dots" title="{{item.purchaseLevel}}">{{item.purchaseLevel}}</td>
                                <td  width="10%">
                                    <button class="btn btn-operate" ng-click="delSelected(item.deliveryNo, $index)">删除</button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="selectedList.length === 0">暂时没有数据</div>
                </div>
                <div class="bottom-area page-bar wrapper-y-sm text-right clearfix">
                    <button type="button" class="btn btn-primary" ng-disabled="selectedList.length==0"
                            ng-click="saveData(orderForm.$valid)">提交
                    </button>
                    <button type="button" class="btn btn-default" ng-click="changeTab(0)">取消</button>
                </div>
            </div>
        </div>
        <div tab heading="详情" active="activeFlag[2]" ng-if="activeFlag[2]">
            <div class="main-area d-b-60" style="top:45px;">
                <div class="m-t-sm form-up-tb clearfix">
                    <div class="form-group col-xs-3 m-b-sm">
                        <label class="col-xs-4 m-b-n text-right max-w-100">代理商名称：</label>
                        <div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.agentName || '-'}}">
                            {{detailInfo.agentName || "-"}}
                        </div>
                    </div>
                    <div class="form-group col-xs-3 m-b-sm">
                        <label class="col-xs-4 m-b-n text-right max-w-100">单据类型：</label>
                        <div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.orderTypeStr || '-'}}">
                            {{detailInfo.orderTypeStr || "-"}}
                        </div>
                    </div>
                    <div class="form-group col-xs-3 m-b-sm">
                        <label class="col-xs-4 m-b-n text-right max-w-100">计划日期：</label>
                        <div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.planDateStr || '-'}}">
                            {{detailInfo.planDateStr || "-"}}
                        </div>
                    </div>
                    <div class="form-group col-xs-3 m-b-sm">
                        <label class="col-xs-7 m-b-n text-right">是否创建发运交货单：</label>
                        <div class="col-xs-5 wrapper-none spill-dots" title="{{detailInfo.isDlvStr || '-'}}">
                            {{detailInfo.isDlvStr || "-"}}
                        </div>
                    </div>
                    <div class="form-group col-xs-3 m-b-sm">
                        <label class="col-xs-4 m-b-n text-right max-w-100">创建时间：</label>
                        <div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.createDateStr || '-'}}">
                            {{detailInfo.createDateStr || "-"}}
                        </div>
                    </div>
                </div>
                <div yb-table-fixed class="table-fixed-wrap" style="top:75px">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{addLeftTbConfig.scrollWidth}}">
                            <thead>
                            <tr>
                                <th ng-repeat="itemCol in addLeftTbConfig.tableCol track by $index" width="{{itemCol.width}}">
                                    <div yb-thead-operate ng-model="itemCol" target-width="purchaseTbConf.scrollWidth"></div>
                                </th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="detailInfo.detailVOList.length > 0">
                        <table class="table-fixed border-none" width="{{addLeftTbConfig.scrollWidth}}">
                            <tbody>
                            <tr ng-repeat="item in detailInfo.detailVOList track by $index">
                                <td class="spill-dots" ng-repeat="itemCol in addLeftTbConfig.tableCol track by $index" width="{{itemCol.width}}"
                                    title="{{item[itemCol.dataField]}}">
                                    <span>{{item[itemCol.dataField]}}</span>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="detailInfo.detailVOList.length === 0">暂时没有数据</div>
                </div>
            </div>
            <div class="bottom-area btn-bar text-center clearfix">
                <button type="button" class="btn btn-default" ng-click="changeTab(0)">返回</button>
            </div>
        </div>
    </div>
</div>